Refactor Node.js server from CommonJS to ESM#400
Merged
electerious merged 6 commits intodevelopfrom Feb 21, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
…Label.js Co-authored-by: electerious <499088+electerious@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor Node.js server from CommonJS to ESM
Refactor Node.js server from CommonJS to ESM
Feb 20, 2026
…ilt-in fetch does not support modifying the Host header
electerious
approved these changes
Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Converts the entire server-side codebase from CommonJS (
require/module.exports) to ES Modules (import/export), following ESM best practices throughout.Core changes
package.json: Added"type": "module"'use strict'directives (implicit in ESM).jsextensions (required by Node.js ESM resolver)Export strategy
Files previously forced to bundle multiple exports into a single object now use proper named exports:
Notable conversions
__dirname→fileURLToPath(import.meta.url)+dirname()require('dotenv').config()→import 'dotenv/config'require()inside functions (src/ui/index.js) → dynamicimport()require.resolve()→createRequire(import.meta.url).resolve()exports.handler = ...(functions/api.js) →export { handler } from '...'CJS interop fixes
Some dependencies don't expose named ESM exports and needed workarounds:
signale: default import + destructure forSignaledate-fns-tz:import { utcToZonedTime } from 'date-fns-tz/esm'(uses the package's ESM entry point)micro/microrouter: default import + destructure forsend,createError,router,del, etc.UI scripts
src/ui/scripts/utils/rangeLabel.jswas using a default import fromconstants/rangeswhich became named exports — updated to destructured named imports.All test files converted to ESM accordingly.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
fastdl.mongodb.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node node ./postinstall.js(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/ava(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/ava rgo/bin/git bash --no�� --noprofile(dns block)If you need me to access, download, or install something from one of these locations, you can either:
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.